//package cn.demo.mq.simple;
//
//import com.rabbitmq.client.*;
//
//import java.io.IOException;
//import java.nio.charset.StandardCharsets;
//import java.util.concurrent.TimeoutException;
//
///**
// * @author Mr.Still
// * @version 1.0.0
// * @date 2021-10-18 15:05
// **/
//public class ReceiverPro {
//
//    public static String QUEUE_NAME = "hello_queue";
//    public static void main(String[] args) {
//        Connection connection = null;
//        Channel channel = null;
//        try {
//            ConnectionFactory factory = new ConnectionFactory();
//            factory.setHost("8.129.129.84");
//            factory.setPort(5672);
//            factory.setVirtualHost("/demo");
//            factory.setUsername("user");
//            factory.setPassword("password");
//            //创建连接对象
//            connection = factory.newConnection();
//            //创建通道
//            channel = connection.createChannel();
//
//            channel.queueDeclare(QUEUE_NAME,false,false,false,null);
//
//
//            DeliverCallback deliverCallback = (consumerTag,delivry) -> {
//              String message = new String(delivry.getBody(), StandardCharsets.UTF_8);
//                System.out.println(message);
//            };
//
//            //队列名，true 消息收到进行删除 ，consumer
//            //监听指定队列
//            channel.basicConsume(QUEUE_NAME,true,deliverCallback,consumerTag->{});
//        } catch (IOException e) {
//            e.printStackTrace();
//        } catch (TimeoutException e) {
//            e.printStackTrace();
//        }
//    }
//}
